package org.example.computor;

import java.util.ArrayList;
import java.util.Iterator;

public class Main {
    public static void main(String[] args) {

            //需求:定义一个集合,存储 唐僧,孙悟空,猪八戒,沙僧,遍历集合,如果遍历到猪八戒,往集合中添加一个白龙马
            ArrayList<String> list = new ArrayList<>();
            list.add("唐僧");
            list.add("孙悟空");
            list.add("猪八戒");
            list.add("沙僧");

            Iterator<String> iterator = list.iterator();
            while(iterator.hasNext()){
                String element = iterator.next();
                if ("猪八戒".equals(element)){
                    list.add("白龙马");
                    break;
                }
            }
            System.out.println(list);

    }


    public static USB method(){
        return new Mouse();
    }
}
